﻿using System;
using System.Collections.Generic;

namespace ConceptsFramework.AbstractConceptElements
{
    public abstract class AbstractBindableConcept
    {
        public List<string> RelationshipsMap = new List<string>();

        /// <summary>
        /// Predicates rules associated with their predicates GUID
        /// </summary>
        public Dictionary<string, Func<AbstractBindableConcept, bool>> Predicates  = new Dictionary<string, Func<AbstractBindableConcept, bool>>();
         
        protected AbstractBindableConcept()
        {
            _ID = Guid.NewGuid().ToString();
        }

        private string _ID;
        public string ID
        {
            get
            {
                return _ID;
            }
        }

        /// <summary>
        /// This method defines wether a type of relationship is authorized or not 
        /// for the current BindableConcept
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public abstract bool IsRelationshipAutorized<T>() where T : AbstractRelationship;

        public string Name { get; set; }


        private List<AbstractBindableConcept> _conceptIsotopes;
        public List<AbstractBindableConcept> ConceptIsotopes
        {
            get
            {
                if (_conceptIsotopes == null)
                    _conceptIsotopes = new List<AbstractBindableConcept>();
                return _conceptIsotopes;
            }
            set
            {
                _conceptIsotopes = value;
            }
        }


        /// <summary>
        /// Create all inverse relationships from the existing relationships 
        /// for the current AbstractConcept.
        /// </summary>
        public abstract void ResolveInverseRelationships();


    }
}
